package com.xy.dao.impl;

import java.util.ArrayList;
import java.util.List;

import com.xy.dao.AdminDao;
import com.xy.model.Admin;
import com.xy.utils.BaseDAO;

public class AdminDaoImpl implements AdminDao {

	@Override
	public Admin adminLogin(String account, String pwd) {
		String sql = "from Admin where account=? and pwd=?";
		String param[] = { account, pwd };

		BaseDAO dao = new BaseDAO();
		Admin admin = (Admin) dao.queryOne(sql, param);

		return admin;
	}

	// ��ҳ��ѯ����
	@Override
	public List<Admin> listByPage(int page) {
		List<Admin> list = new ArrayList<Admin>();
		String sql = "from Admin order by createdate";

		list = BaseDAO.queryByPage(sql, null, page, 20);

		return list;

	}

	// ��ѯ��������
	@Override
	public List<Admin> list(String name) {
		List<Admin> list = new ArrayList<Admin>();
		String sql = "from Admin where name like ?";
		String param[] = { name };
		list = BaseDAO.query(sql, param);

		return list;

	}

	// �޸�����
	@Override
	public boolean update(Admin admin) {
		boolean result = BaseDAO.update(admin);
		return result;
	}

	// ɾ������
	@Override
	public boolean delete(Admin admin) {
		boolean result = BaseDAO.delete(admin);
		return result;
	}

	// ��������
	public boolean add(Admin admin) {
		boolean result = BaseDAO.add(admin);
		return result;
	}

}
